#ifndef _X_LOCK_QUEUE_H
#define _X_LOCK_QUEUE_H
#include <deque>
#include <mutex>
#include "xDef.h"
namespace xNet
{
    template<class T>
    NET_ENGINE_CORE_API class xLockQueue
    {
        public:
            ~xLockQueue()
            {
                m_que.clear();
            }
        public:
            void Push(T* t)
            {
                std::lock_guard<std::mutex> guard(m_mutex);
                m_que.push_back(t);
            }
            T* Pop()
            {
                std::lock_guard<std::mutex> guard(m_mutex);
                if(!m_que.empty())
                {
                    T* t = m_que.front();
                    m_que.pop_front();
                    return t;
                }
                return nullptr;
            }
        protected:
            std::deque<T*> m_que;
            std::mutex m_mutex;
    };
}

#endif